import { axios } from '@/utils/request'

const api = {
  partner: '/partners',
  websiteLetter: '/website-letter'
}

export function savePartner (params) {
  return axios({
    url: api.partner + (params.hasOwnProperty('id') ? '/' + params.id : ''),
    method: params.hasOwnProperty('id') ? 'patch' : 'post',
    params: params
  })
}

export function getPartnerList (params) {
  return axios({
    url: api.partner,
    method: 'get',
    responseType: params.hasOwnProperty('export') ? 'blob' : 'json', // 导出 下载
    params: params
  })
}

export function deletePartner (id) {
  return axios({
    url: api.partner + '/' + id,
    method: 'delete'
  })
}

export function getWebsiteLetterList (params) {
  return axios({
    url: api.websiteLetter,
    method: 'get',
    params
  })
}

export function getWebsiteLetter (id) {
  return axios({
    url: api.websiteLetter + '/' + id,
    method: 'get'
  })
}

export function deleteWebsiteLetter (id) {
  return axios({
    url: api.websiteLetter + '/' + id,
    method: 'delete'
  })
}

export function saveWebsiteLetter (params) {
  return axios({
    url: api.websiteLetter + (params.hasOwnProperty('id') ? '/' + params.id : ''),
    method: params.hasOwnProperty('id') ? 'patch' : 'post',
    data: params
  })
}
